package com.ziyueyuwen.xiniao.dao;

import com.alibaba.fastjson.JSONObject;
import com.ziyueyuwen.xiniao.bean.homework.AnswerData;
import com.ziyueyuwen.xiniao.bean.homework.HomeworkMarkData;
import com.ziyueyuwen.xiniao.bean.homework.HomeworkRecordNotMarkVO;
import com.ziyueyuwen.xiniao.bean.homework.ZyHomeworkRecordDO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

import static com.ziyueyuwen.xiniao.util.ConstUtil.*;

/**
 * @author jun 2018/12/22.
 */
public interface ZyHomeworkRecordMapper {
    /**
     * 添加记录
     *
     * @param zyHomeworkRecord ZyHomeworkRecordDO
     * @return Boolean
     */
    Boolean add(ZyHomeworkRecordDO zyHomeworkRecord);

    /**
     * 更新学生答案
     *
     * @param id             Integer
     * @param answerInfoList List<AnswerData>
     * @return Boolean
     */
    Boolean updateStudentAnswer(@Param(KEY_ID) Integer id,
                                @Param(KEY_ANSWER_INFO_LIST) List<AnswerData> answerInfoList);

    /**
     * 更新学生课堂互动记录
     *
     * @param id                  Integer
     * @param classroomTestRecord JSONObject
     * @return Boolean
     */
    Boolean updateClassroomTestRecord(@Param(KEY_ID) Integer id,
                                      @Param(KEY_CLASSROOM_TEST_RECORD) JSONObject classroomTestRecord);

    /**
     * 根据学生id和课节id获取数据
     *
     * @param studentId String
     * @param lessonId  Integer
     * @return ZyHomeworkRecordDO
     */
    ZyHomeworkRecordDO getByStudentIdAndLessonId(@Param(KEY_STUDENT_ID) String studentId,
                                                 @Param(KEY_LESSON_ID) Integer lessonId);

    /**
     * 根据班级id获取数据
     *
     * @param classId Integer
     * @return List<ZyHomeworkRecordDO>
     */
    List<ZyHomeworkRecordDO> listByClassId(Integer classId);

    /**
     * 根据id获取数据
     *
     * @param id Integer
     * @return ZyHomeworkRecordDO
     */
    ZyHomeworkRecordDO getById(Integer id);

    /**
     * 完成作业
     *
     * @param id Integer
     * @return Boolean
     */
    Boolean finisHomework(Integer id);

    /**
     * 获取未批改记录
     *
     * @param userAccount
     * @return
     */
    List<HomeworkRecordNotMarkVO> listHomeworkRecordNotMark(@Param("userAccount") String userAccount);

    /**
     * 评分
     *
     * @param id             Integer
     * @param markInfo       HomeworkMarkData
     * @param answerInfoList List<AnswerData>
     * @return Boolean
     */
    Boolean markHomeworkRecord(@Param(KEY_ID) Integer id,
                               @Param(KEY_MARK_INFO) HomeworkMarkData markInfo,
                               @Param(KEY_ANSWER_INFO_LIST) List<AnswerData> answerInfoList);

    /**
     * 获取作业状态
     *
     * @param studentId String
     * @param lessonId  Integer
     * @return HomeworkStatusEnum
     */
    ZyHomeworkRecordDO getHomeworkStatus(@Param(KEY_STUDENT_ID) String studentId,
                                         @Param(KEY_LESSON_ID) Integer lessonId);

    /**
     * 获取作业记录
     *
     * @param courseId
     * @param homeworkIndex
     * @return
     */
    List<ZyHomeworkRecordDO> getByCourseIdAndLessonIndex(@Param("courseId") Integer courseId, @Param("homeworkIndex") Integer homeworkIndex);
}
